/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.kamai.xmlparser.writing;

import com.edu.kamai.xml.beans.paperXML;
import com.edu.kamai.xml.beans.writing.writingQuestion;
import com.edu.kamai.xml.beans.writing.writingXML;
import com.edu.kamai.xmlparser.paperGeneration;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.jdom.Document;
import org.jdom.Element;


/**
 *
 * @author xyzhu
 */
public class writingPaperGeneration extends paperGeneration {
    
    
    public writingPaperGeneration(paperXML xml){
        //super();
        super(xml.getPaperRoleID());
        this.wxml = (writingXML) xml;
    }
    
    public void generateBody(){
        document = new Document();
        Element root = generateHead();
        int numOfQuestion = wxml.getWritingquestionList().size();
        for(int i = 0;i < numOfQuestion; i++){
            writingQuestion wq = wxml.getWritingquestionList().get(i);
            Element child = new Element("writingQestion");
            child.addContent(new Element("paperTitle").setText(wq.getPaperTitle()));
            child.addContent(new Element("paperDescription").setText(wq.getPaperDescription()));
            child.addContent(new Element("timeLimit").setText(wq.getTimeLimit()));
            child.addContent(new Element("mp3Path").setText(wq.getMp3Path()));
            child.addContent(new Element("MainTxt").setText(wq.getMainTxt()));
            root.addContent(child);
        }
        document.setContent(root);
    }
    
    private writingXML wxml;
    
}
